package com.ruoyi.web.controller.basicInformation;

import java.util.List;
import java.util.Arrays;

import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.basicInformation.vo.TInformationRegisterVo;
import com.ruoyi.system.basicInformation.bo.TInformationRegisterQueryBo;
import com.ruoyi.system.basicInformation.bo.TInformationRegisterAddBo;
import com.ruoyi.system.basicInformation.bo.TInformationRegisterEditBo;
import com.ruoyi.system.basicInformation.service.ITInformationRegisterService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 信息登记Controller
 * 
 * @author ruoyi
 * @date 2021-05-26
 */
@Api(value = "信息登记控制器", tags = {"信息登记管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/basicInformation/informationRegister")
public class TInformationRegisterController extends BaseController {

    private final ITInformationRegisterService iTInformationRegisterService;

    /**
     * 查询信息登记列表
     */
    @ApiOperation("查询信息登记列表")
    @PreAuthorize("@ss.hasPermi('basicInformation:informationRegister:list')")
    @GetMapping("/list")
    public TableDataInfo<TInformationRegisterVo> list(TInformationRegisterQueryBo bo) {
        startPage();
        List<TInformationRegisterVo> list = iTInformationRegisterService.queryList(bo);
        return getDataTable(list);
    }

    /**
     * 导出信息登记列表
     */
    @ApiOperation("导出信息登记列表")
    @PreAuthorize("@ss.hasPermi('basicInformation:informationRegister:export')")
    @Log(title = "信息登记", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<TInformationRegisterVo> export(TInformationRegisterQueryBo bo) {
        List<TInformationRegisterVo> list = iTInformationRegisterService.queryList(bo);
        ExcelUtil<TInformationRegisterVo> util = new ExcelUtil<TInformationRegisterVo>(TInformationRegisterVo.class);
        return util.exportExcel(list, "信息登记");
    }

    /**
     * 获取信息登记详细信息
     */
    @ApiOperation("获取信息登记详细信息")
    @PreAuthorize("@ss.hasPermi('basicInformation:informationRegister:query')")
    @GetMapping("/{id}")
    public AjaxResult<TInformationRegisterVo> getInfo(@PathVariable("id" ) Long id) {
        return AjaxResult.success(iTInformationRegisterService.queryById(id));
    }

    /**
     * 新增信息登记
     */
    @ApiOperation("新增信息登记")
    @PreAuthorize("@ss.hasPermi('basicInformation:informationRegister:add')")
    @Log(title = "信息登记", businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult<Void> add(@RequestBody TInformationRegisterAddBo bo) {
        return toAjax(iTInformationRegisterService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 修改信息登记
     */
    @ApiOperation("修改信息登记")
    @PreAuthorize("@ss.hasPermi('basicInformation:informationRegister:edit')")
    @Log(title = "信息登记", businessType = BusinessType.UPDATE)
    @PutMapping()
    public AjaxResult<Void> edit(@RequestBody TInformationRegisterEditBo bo) {
        return toAjax(iTInformationRegisterService.updateByEditBo(bo) ? 1 : 0);
    }

    /**
     * 删除信息登记
     */
    @ApiOperation("删除信息登记")
    @PreAuthorize("@ss.hasPermi('basicInformation:informationRegister:remove')")
    @Log(title = "信息登记" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult<Void> remove(@PathVariable Long[] ids) {
        return toAjax(iTInformationRegisterService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
    }
}
